/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Valuador2.java
 *
 * Created on 28-oct-2009, 8:48:29
 */

package scapi.gui;

import java.rmi.Naming;
import java.rmi.RemoteException;
import javax.sql.rowset.Joinable;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import scapi.entidades.CatalogoProducto;
import scapi.entidades.Joya;
import scapi.entidades.Producto;
import scapi.servidor.servidores.ServidorACatalogoProd;
import scapi.servidor.servidores.ServidorACatalogoProdImp;
import scapi.servidor.servidores.ServidorAEmpenio;
import scapi.utilerias.EValidacion;
import scapi.utilerias.ExcepcionValidacion;

/**
 *
 * @author Sideroz Inc.
 */
public class Valuador extends javax.swing.JFrame {
   // private ServidorAEmpenio servAEmpenio;
    private ServidorACatalogoProd servACProducto;
    

    /** Creates new form Valuador2 */
    public Valuador() {
       initComponents();
        try{
          //  servAEmpenio = (ServidorAEmpenio) Naming.lookup("servEmpenio");
            servACProducto =  (ServidorACatalogoProd) Naming.lookup("servCProducto");
            CatalogoProducto[] catalogo = servACProducto.consultaCatalogoProducto();
            System.out.println("La longitud de catalogo "+catalogo.length);
            CBCategoria.setModel(new DefaultComboBoxModel(catalogo));
           

        }catch(Exception e){
            e.printStackTrace();
        }
         
        JPVjoyas.setVisible(false);
        JPVmarcamodelo.setVisible(false);

        pack();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        JLVnom_pro = new javax.swing.JLabel();
        JLVdesc_pro = new javax.swing.JLabel();
        SPVdescripcion = new javax.swing.JScrollPane();
        TAVdescripcion = new javax.swing.JTextArea();
        JLVcategoria = new javax.swing.JLabel();
        CBVcategoria = new javax.swing.JComboBox();
        TFVnom_pro = new javax.swing.JTextField();
        JPVjoyas = new javax.swing.JPanel();
        JLVmaterial = new javax.swing.JLabel();
        TFVmaterial = new javax.swing.JTextField();
        CBVplata = new javax.swing.JCheckBox();
        CBVdiamante = new javax.swing.JCheckBox();
        CBVotros = new javax.swing.JCheckBox();
        CBVoro = new javax.swing.JCheckBox();
        JPVmarcamodelo = new javax.swing.JPanel();
        TFVmodelo = new javax.swing.JTextField();
        TFVmarca = new javax.swing.JTextField();
        JLVmarca = new javax.swing.JLabel();
        JLVmodelo = new javax.swing.JLabel();
        TFVavaluo = new javax.swing.JTextField();
        JLVavaluo = new javax.swing.JLabel();
        CBVpresentacion = new javax.swing.JComboBox();
        JLVpres_pro = new javax.swing.JLabel();
        TFVprestamo = new javax.swing.JTextField();
        CBVcambiarPrestamo = new javax.swing.JCheckBox();
        JLVprestamo = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        CBCategoria = new javax.swing.JComboBox();
        jButton3 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        JMarchivo = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        JMedicion = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Avaluo");
        setLocationByPlatform(true);
        setResizable(false);

        JLVnom_pro.setText("Producto");

        JLVdesc_pro.setText("Descripcion");

        TAVdescripcion.setColumns(20);
        TAVdescripcion.setLineWrap(true);
        TAVdescripcion.setRows(5);
        SPVdescripcion.setViewportView(TAVdescripcion);

        JLVcategoria.setText("Categoria");

        CBVcategoria.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--Seleccionar--", "Joyeria", "Electronica" }));
        CBVcategoria.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                CBVcategoriaItemStateChanged(evt);
            }
        });

        JPVjoyas.setEnabled(false);

        JLVmaterial.setText("Material(es)");
        JLVmaterial.setEnabled(false);

        TFVmaterial.setEnabled(false);

        CBVplata.setText("Plata");
        CBVplata.setEnabled(false);

        CBVdiamante.setText("Diamante");
        CBVdiamante.setEnabled(false);

        CBVotros.setText("Otros");
        CBVotros.setEnabled(false);
        CBVotros.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CBVotrosActionPerformed(evt);
            }
        });

        CBVoro.setText("Oro");
        CBVoro.setEnabled(false);

        javax.swing.GroupLayout JPVjoyasLayout = new javax.swing.GroupLayout(JPVjoyas);
        JPVjoyas.setLayout(JPVjoyasLayout);
        JPVjoyasLayout.setHorizontalGroup(
            JPVjoyasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JPVjoyasLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(JPVjoyasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(JLVmaterial)
                    .addComponent(CBVotros))
                .addGap(21, 21, 21)
                .addGroup(JPVjoyasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(JPVjoyasLayout.createSequentialGroup()
                        .addComponent(CBVoro)
                        .addGap(18, 18, 18)
                        .addComponent(CBVplata)
                        .addGap(18, 18, 18)
                        .addComponent(CBVdiamante, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(TFVmaterial, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE))
                .addContainerGap())
        );
        JPVjoyasLayout.setVerticalGroup(
            JPVjoyasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JPVjoyasLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(JPVjoyasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(JLVmaterial)
                    .addComponent(CBVoro)
                    .addComponent(CBVplata)
                    .addComponent(CBVdiamante))
                .addGap(7, 7, 7)
                .addGroup(JPVjoyasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(CBVotros)
                    .addComponent(TFVmaterial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        JPVmarcamodelo.setEnabled(false);

        TFVmodelo.setEnabled(false);

        TFVmarca.setEnabled(false);
        TFVmarca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TFVmarcaActionPerformed(evt);
            }
        });

        JLVmarca.setText("Marca");
        JLVmarca.setEnabled(false);

        JLVmodelo.setText("Modelo");
        JLVmodelo.setEnabled(false);

        javax.swing.GroupLayout JPVmarcamodeloLayout = new javax.swing.GroupLayout(JPVmarcamodelo);
        JPVmarcamodelo.setLayout(JPVmarcamodeloLayout);
        JPVmarcamodeloLayout.setHorizontalGroup(
            JPVmarcamodeloLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JPVmarcamodeloLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(JPVmarcamodeloLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(JLVmodelo)
                    .addComponent(JLVmarca))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(JPVmarcamodeloLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(TFVmodelo, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE)
                    .addComponent(TFVmarca, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE))
                .addContainerGap())
        );
        JPVmarcamodeloLayout.setVerticalGroup(
            JPVmarcamodeloLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JPVmarcamodeloLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(JPVmarcamodeloLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(JLVmarca)
                    .addComponent(TFVmarca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(JPVmarcamodeloLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(JLVmodelo)
                    .addComponent(TFVmodelo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        TFVavaluo.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                TFVavaluoFocusLost(evt);
            }
        });

        JLVavaluo.setText("Avaluo");

        CBVpresentacion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Muy buena", "Buena", "Regular", "Mala", "Muy mala" }));
        CBVpresentacion.setSelectedIndex(1);
        CBVpresentacion.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                CBVpresentacionItemStateChanged(evt);
            }
        });

        JLVpres_pro.setText("Presentacion");

        TFVprestamo.setEditable(false);

        CBVcambiarPrestamo.setText("Cambiar");
        CBVcambiarPrestamo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CBVcambiarPrestamoActionPerformed(evt);
            }
        });

        JLVprestamo.setText("Prestamo");

        jLabel1.setText("Catalogo");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(JLVnom_pro)
                            .addComponent(JLVdesc_pro)
                            .addComponent(JLVcategoria))
                        .addGap(35, 35, 35)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(CBVcategoria, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(SPVdescripcion)
                            .addComponent(TFVnom_pro, javax.swing.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE)
                            .addComponent(JPVmarcamodelo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(JPVjoyas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(JLVavaluo)
                            .addComponent(jLabel1)
                            .addComponent(JLVpres_pro)
                            .addComponent(JLVprestamo))
                        .addGap(33, 33, 33)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(TFVprestamo, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(CBVcambiarPrestamo, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE))
                            .addComponent(CBVpresentacion, 0, 291, Short.MAX_VALUE)
                            .addComponent(TFVavaluo, javax.swing.GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE)
                            .addComponent(CBCategoria, 0, 291, Short.MAX_VALUE))))
                .addGap(29, 29, 29))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(JLVnom_pro)
                    .addComponent(TFVnom_pro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(JLVdesc_pro)
                    .addComponent(SPVdescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(JLVcategoria)
                    .addComponent(CBVcategoria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(JPVjoyas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(JPVmarcamodelo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 25, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(CBCategoria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(JLVavaluo)
                    .addComponent(TFVavaluo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(JLVpres_pro)
                    .addComponent(CBVpresentacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(JLVprestamo)
                    .addComponent(CBVcambiarPrestamo)
                    .addComponent(TFVprestamo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jButton3.setText("Imprimir");

        jButton2.setText("Aceptar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton1.setText("Cancelar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        JMarchivo.setText("Archivo");

        jMenuItem1.setText("jMenuItem1");
        JMarchivo.add(jMenuItem1);

        jMenuBar1.add(JMarchivo);

        JMedicion.setText("Edicion");
        jMenuBar1.add(JMedicion);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(172, Short.MAX_VALUE)
                .addComponent(jButton3)
                .addGap(18, 18, 18)
                .addComponent(jButton2)
                .addGap(17, 17, 17)
                .addComponent(jButton1)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton3)
                    .addComponent(jButton2)
                    .addComponent(jButton1))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void CBVcambiarPrestamoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CBVcambiarPrestamoActionPerformed
        if (CBVcambiarPrestamo.isSelected())
	    TFVprestamo.setEditable(true);
	else
	    TFVprestamo.setEditable(false);
}//GEN-LAST:event_CBVcambiarPrestamoActionPerformed

    private void TFVmarcaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TFVmarcaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_TFVmarcaActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

	try {
	    String nombre = EValidacion.campoVacio(TFVnom_pro.getText(),"Nombre producto");
	    String desc = EValidacion.vacio(TAVdescripcion.getText(), "Descripcion");
	    String otroMat;
	    String marca;
	    String modelo;
	    float prestamo;
	    if (CBVcategoria.getSelectedIndex() == 0)
                throw new ExcepcionValidacion("Debe elegir una opcion de categoria");
		//JOptionPane.showMessageDialog(this, "Debe elegir una opcion de categoria", "ERROR", JOptionPane.ERROR_MESSAGE);
	    else {
		if (CBVcategoria.getSelectedIndex() == 1) {
		    if (!CBVoro.isSelected() && !CBVplata.isSelected() && !CBVdiamante.isSelected() && !CBVotros.isSelected())
			throw new ExcepcionValidacion("Debe elegir un material");
                        //JOptionPane.showMessageDialog(this, "Debe elegir un material", "ERROR", JOptionPane.ERROR_MESSAGE);
		    if (CBVotros.isSelected())
			otroMat = EValidacion.cadenaCorrecta(TFVmaterial.getText(), "Material");
		}
		else {
		    marca = EValidacion.campoVacio(TFVmarca.getText(), "Marca");
		    modelo = EValidacion.campoVacio(TFVmodelo.getText(), "Modelo");
		}
	    }
	    float avaluo = EValidacion.flotante(TFVavaluo.getText(), "Avaluo");
	    if (CBVcambiarPrestamo.isSelected())
		prestamo = EValidacion.flotante(TFVprestamo.getText(), "Prestamo");
	    else{

		prestamo = EValidacion.flotante(TFVprestamo.getText(), "Prestamo");

                if(prestamo > avaluo)
                    throw new ExcepcionValidacion("El prestamo no puede ser mayor que el avaluo");
            }

           
	} catch (ExcepcionValidacion e) {

	    JOptionPane.showMessageDialog(this, e.getMessage(), "ERROR", JOptionPane.ERROR_MESSAGE);
	    
	}



    }//GEN-LAST:event_jButton2ActionPerformed

    private void CBVcategoriaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_CBVcategoriaItemStateChanged
	// TODO add your handling code here:
	if (CBVcategoria.getSelectedIndex() != 0){
	    if (CBVcategoria.getSelectedIndex() == 1) {
		//Activar panel de joyas
                JPVjoyas.setVisible(true);
		JPVjoyas.setEnabled(true);
		JLVmaterial.setEnabled(true);
		CBVoro.setEnabled(true);
		CBVplata.setEnabled(true);
		CBVdiamante.setEnabled(true);
		CBVotros.setEnabled(true);
		if (CBVotros.isSelected())
		    TFVmaterial.setEnabled(true);
		//Desactivar panel de prenda
                JPVmarcamodelo.setVisible(false);
		JPVmarcamodelo.setEnabled(false);
		JLVmarca.setEnabled(false);
		TFVmarca.setEnabled(false);
		JLVmodelo.setEnabled(false);
		TFVmodelo.setEnabled(false);
                pack();
	    } else {
		//Activar panel de prenda
                JPVmarcamodelo.setVisible(true);
		JPVmarcamodelo.setEnabled(true);
		JLVmarca.setEnabled(true);
		TFVmarca.setEnabled(true);
		JLVmodelo.setEnabled(true);
		TFVmodelo.setEnabled(true);
		//Desactivar panel de joyas
                JPVjoyas.setVisible(false);
		JPVjoyas.setEnabled(false);
		JLVmaterial.setEnabled(false);
		CBVoro.setEnabled(false);
		CBVplata.setEnabled(false);
		CBVdiamante.setEnabled(false);
		CBVotros.setEnabled(false);
		TFVmaterial.setEnabled(false);
                pack();
	    }
	} else {
            JPVjoyas.setVisible(false);
	    //Desactivar panel de joyas
	    JPVjoyas.setEnabled(false);
	    JLVmaterial.setEnabled(false);
	    CBVoro.setEnabled(false);
	    CBVplata.setEnabled(false);
	    CBVdiamante.setEnabled(false);
	    CBVotros.setEnabled(false);
	    TFVmaterial.setEnabled(false);
            JPVjoyas.setVisible(false);
	    //Desactivar panel de prenda
	    JPVmarcamodelo.setEnabled(false);
	    JLVmarca.setEnabled(false);
	    TFVmarca.setEnabled(false);
	    JLVmodelo.setEnabled(false);
	    TFVmodelo.setEnabled(false);
            pack();
	}
    }//GEN-LAST:event_CBVcategoriaItemStateChanged

    private void CBVotrosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CBVotrosActionPerformed
	// TODO add your handling code here:
	System.out.println(evt.getActionCommand());
	if (CBVotros.isSelected())
	    TFVmaterial.setEnabled(true);
	else
	    TFVmaterial.setEnabled(false);
    }//GEN-LAST:event_CBVotrosActionPerformed

    private void TFVavaluoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_TFVavaluoFocusLost
	// TODO add your handling code here:
	CBVpresentacionItemStateChanged(null);
    }//GEN-LAST:event_TFVavaluoFocusLost

    private void CBVpresentacionItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_CBVpresentacionItemStateChanged
	// TODO add your handling code here:
	System.out.println(CBVpresentacion.getSelectedIndex());
	switch (CBVpresentacion.getSelectedIndex()) {
	    case 0:
		try {
		    float pres = (float) (0.85 * EValidacion.flotante(TFVavaluo.getText(), "Avaluo"));
		    TFVprestamo.setText("" + pres);
		} catch (ExcepcionValidacion e){
		    System.out.println(e.getMessage());
		}
		break;
	    case 1:
		try {
		    float pres = (float) (0.75 * EValidacion.flotante(TFVavaluo.getText(), "Avaluo"));
		    TFVprestamo.setText("" + pres);
		} catch (ExcepcionValidacion e){
		    System.out.println(e.getMessage());
		}
		break;
	    case 2:
		try {
		    float pres = (float) (0.65 * EValidacion.flotante(TFVavaluo.getText(), "Avaluo"));
		    TFVprestamo.setText("" + pres);
		} catch (ExcepcionValidacion e){
		    System.out.println(e.getMessage());
		}
		break;
	    case 3:
		try {
		    float pres = (float) (0.55 * EValidacion.flotante(TFVavaluo.getText(), "Avaluo"));
		    TFVprestamo.setText("" + pres);
		} catch (ExcepcionValidacion e){
		    System.out.println(e.getMessage());
		}
		break;
	    case 4:
		try {
		    float pres = (float) (0.45 * EValidacion.flotante(TFVavaluo.getText(), "Avaluo"));
		    TFVprestamo.setText("" + pres);
		} catch (ExcepcionValidacion e){
		    System.out.println(e.getMessage());
		}
		break;
	    default:
		break;

	}
    }//GEN-LAST:event_CBVpresentacionItemStateChanged

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
	// TODO add your handling code here:
	System.exit(0);
    }//GEN-LAST:event_jButton1ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
	try
	        {
	            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
	        }
	        catch (Exception e) {
	            e.printStackTrace();
	        }

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Valuador().setVisible(true);

            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox CBCategoria;
    private javax.swing.JCheckBox CBVcambiarPrestamo;
    private javax.swing.JComboBox CBVcategoria;
    private javax.swing.JCheckBox CBVdiamante;
    private javax.swing.JCheckBox CBVoro;
    private javax.swing.JCheckBox CBVotros;
    private javax.swing.JCheckBox CBVplata;
    private javax.swing.JComboBox CBVpresentacion;
    private javax.swing.JLabel JLVavaluo;
    private javax.swing.JLabel JLVcategoria;
    private javax.swing.JLabel JLVdesc_pro;
    private javax.swing.JLabel JLVmarca;
    private javax.swing.JLabel JLVmaterial;
    private javax.swing.JLabel JLVmodelo;
    private javax.swing.JLabel JLVnom_pro;
    private javax.swing.JLabel JLVpres_pro;
    private javax.swing.JLabel JLVprestamo;
    private javax.swing.JMenu JMarchivo;
    private javax.swing.JMenu JMedicion;
    private javax.swing.JPanel JPVjoyas;
    private javax.swing.JPanel JPVmarcamodelo;
    private javax.swing.JScrollPane SPVdescripcion;
    private javax.swing.JTextArea TAVdescripcion;
    private javax.swing.JTextField TFVavaluo;
    private javax.swing.JTextField TFVmarca;
    private javax.swing.JTextField TFVmaterial;
    private javax.swing.JTextField TFVmodelo;
    private javax.swing.JTextField TFVnom_pro;
    private javax.swing.JTextField TFVprestamo;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables

}
